﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using Autodesk.Revit.UI;
using YArchitech.LIB;
using YArchitech.LIB.YJKControls;

namespace HYElectricSetting
{
	public partial class CreateItemForm : System.Windows.Forms.Form
	{
		public string NewName { get; set; }

		public string BaseName { get; set; }

		public CreateItemForm(string title, List<string> names)
		{
			this.InitializeComponent();
			this.formTitle = title;
			this.lstBaseName = names;
			this.NewName = string.Empty;
			this.BaseName = string.Empty;
		}

		private void CreateItemForm_Load(object sender, EventArgs e)
		{
			//base.Icon = Resource.YArchitechIcon;
			this.Text = this.formTitle;
			this.InitBaseNameCombox();
			this.txtName.Focus();
		}

		private void InitBaseNameCombox()
		{
			foreach (string item in this.lstBaseName)
			{
				this.cmbBaseName.Items.Add(item);
			}
			bool flag = this.cmbBaseName.Items.Count > 0;
			if (flag)
			{
				this.cmbBaseName.SelectedIndex = 0;
			}
		}

		private void btnOk_Click(object sender, EventArgs e)
		{
			string text = this.txtName.Text.Trim();
			bool flag = string.IsNullOrEmpty(text);
			if (flag)
			{
				TaskDialog.Show("盈建科提示", "名称不能为空。");
				this.txtName.Focus();
			}
			else
			{
				bool flag2 = this.lstBaseName.Contains(text);
				if (flag2)
				{
					TaskDialog.Show("盈建科提示", "名称已经存在，请重新输入。");
					this.txtName.Focus();
				}
				else
				{
					this.NewName = text;
					this.BaseName = (string)this.cmbBaseName.SelectedItem;
					base.DialogResult = DialogResult.OK;
				}
			}
		}

		private string formTitle;

		private List<string> lstBaseName;
	}
}
